import 'package:chathouse/widgets/form_widgets/form_widgets.dart';

class PreQuestionBeanTool {
  int? raw;
  int? total;
  List<PreQuestionBean>? rows;
  int? code;
  String? msg;
  int? serviceId;
  String? serviceName;

  bool get isRequestSuccess {
    return code == 200;
  }

  PreQuestionBeanTool(
      {this.raw,
      this.total,
      this.rows,
      this.code,
      this.msg,
      this.serviceId,
      this.serviceName});

  PreQuestionBeanTool.fromJson(Map<String, dynamic> json) {
    raw = json['raw'];
    total = json['total'];
    if (json['rows'] != null) {
      rows = <PreQuestionBean>[];
      json['rows'].forEach((v) {
        rows!.add(new PreQuestionBean.fromJson(v));
      });
    }
    code = json['code'];
    msg = json['msg'];
    serviceId = json['serviceId'];
    serviceName = json['serviceName'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['raw'] = this.raw;
    data['total'] = this.total;
    if (this.rows != null) {
      data['rows'] = this.rows!.map((v) => v.toJson()).toList();
    }
    data['code'] = this.code;
    data['msg'] = this.msg;
    data['serviceId'] = this.serviceId;
    data['serviceName'] = this.serviceName;
    return data;
  }
}

class PreQuestionBean {
  dynamic searchValue;
  String? createBy;
  String? createTime;
  String? updateBy;
  String? updateTime;
  String? remark;
  int? problemId;
  int? serviceId;
  String? problemName;
  String? problemType;
  String? required;
  List<MyList>? list;
  dynamic answer;
  bool? exhibition;
  int? problemSort;
  int? pagesNum;
  String? status;
  dynamic firstProblemId;
  dynamic firstOptionCode;
  String? delFlag;
  int? version;

  // MyList to KeyValueBean
  List<KeyValueBean> get getKeyValueArrayByList {
    return list?.map((e) {
          return KeyValueBean("${e.optionCode ?? ""}", e.optionValue ?? "");
        }).toList() ??
        [];
  }

  PreQuestionBean(
      {this.searchValue,
      this.createBy,
      this.createTime,
      this.updateBy,
      this.updateTime,
      this.remark,
      this.problemId,
      this.serviceId,
      this.problemName,
      this.problemType,
      this.required,
      this.list,
      this.answer,
      this.exhibition,
      this.problemSort,
      this.pagesNum,
      this.status,
      this.firstProblemId,
      this.firstOptionCode,
      this.delFlag,
      this.version});

  PreQuestionBean.fromJson(Map<String, dynamic> json) {
    searchValue = json['searchValue'];
    createBy = json['createBy'];
    createTime = json['createTime'];
    updateBy = json['updateBy'];
    updateTime = json['updateTime'];
    remark = json['remark'];
    problemId = json['problemId'];
    serviceId = json['serviceId'];
    problemName = json['problemName'];
    problemType = json['problemType'];
    required = json['required'];
    if (json['list'] != null) {
      list = <MyList>[];
      json['list'].forEach((v) {
        list!.add(new MyList.fromJson(v));
      });
    }
    answer = json['answer'];
    exhibition = json['exhibition'];
    problemSort = json['problemSort'];
    pagesNum = json['pagesNum'];
    status = json['status'];
    firstProblemId = json['firstProblemId'];
    firstOptionCode = json['firstOptionCode'];
    delFlag = json['delFlag'];
    version = json['version'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['searchValue'] = this.searchValue;
    data['createBy'] = this.createBy;
    data['createTime'] = this.createTime;
    data['updateBy'] = this.updateBy;
    data['updateTime'] = this.updateTime;
    data['remark'] = this.remark;

    data['problemId'] = this.problemId;
    data['serviceId'] = this.serviceId;
    data['problemName'] = this.problemName;
    data['problemType'] = this.problemType;
    data['required'] = this.required;
    if (this.list != null) {
      data['list'] = this.list!.map((v) => v.toJson()).toList();
    }
    data['answer'] = this.answer;
    data['exhibition'] = this.exhibition;
    data['problemSort'] = this.problemSort;
    data['pagesNum'] = this.pagesNum;
    data['status'] = this.status;
    data['firstProblemId'] = this.firstProblemId;
    data['firstOptionCode'] = this.firstOptionCode;
    data['delFlag'] = this.delFlag;
    data['version'] = this.version;
    return data;
  }
}

Map<String, dynamic> toJson() {
  final Map<String, dynamic> data = new Map<String, dynamic>();
  return data;
}

class MyList {
  dynamic searchValue;
  String? createBy;
  String? createTime;
  String? updateBy;
  dynamic updateTime;
  String? remark;
  int? optionCode;
  int? problemId;
  String? problemName;
  String? optionValue;
  int? optionSort;
  String? status;
  String? delFlag;
  int? version;

  MyList(
      {this.searchValue,
      this.createBy,
      this.createTime,
      this.updateBy,
      this.updateTime,
      this.remark,
      this.optionCode,
      this.problemId,
      this.problemName,
      this.optionValue,
      this.optionSort,
      this.status,
      this.delFlag,
      this.version});

  MyList.fromJson(Map<String, dynamic> json) {
    searchValue = json['searchValue'];
    createBy = json['createBy'];
    createTime = json['createTime'];
    updateBy = json['updateBy'];
    updateTime = json['updateTime'];
    remark = json['remark'];
    optionCode = json['optionCode'];
    problemId = json['problemId'];
    problemName = json['problemName'];
    optionValue = json['optionValue'];
    optionSort = json['optionSort'];
    status = json['status'];
    delFlag = json['delFlag'];
    version = json['version'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['searchValue'] = this.searchValue;
    data['createBy'] = this.createBy;
    data['createTime'] = this.createTime;
    data['updateBy'] = this.updateBy;
    data['updateTime'] = this.updateTime;
    data['remark'] = this.remark;
    data['optionCode'] = this.optionCode;
    data['problemId'] = this.problemId;
    data['problemName'] = this.problemName;
    data['optionValue'] = this.optionValue;
    data['optionSort'] = this.optionSort;
    data['status'] = this.status;
    data['delFlag'] = this.delFlag;
    data['version'] = this.version;
    return data;
  }
}
